var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("BaseModuleUI"),
    a = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("Game"),
    s = e("ObjectPool"),
    l = cc._decorator,
    c = l.ccclass,
    d = l.property,
    h = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.soldier_ske = null),
                (t.soldier_hp_mask = null),
                (t.soldier_skeleton = []),
                (t.be_hit_ske = null),
                (t.team_info = r.TeamInfo.rest_team),
                (t.node_info = null),
                (t.have_hp = 0),
                (t.is_die = !1),
                (t.soldier_kill_id = 0),
                t
            );
        }
        return (
            __extends(t, e),
            (t.prototype.setNodeInfo = function (e) {
                (this.team_info = e.team),
                    (this.node_info = e.info),
                    (this.have_hp = this.node_info.ma_hp),
                    0 != this.soldier_skeleton.length && (this.soldier_ske.skeletonData = this.soldier_skeleton[e.id]),
                    (this.soldier_ske.defaultSkin = this.team_info % 2 == 0 ? "red" : "blue"),
                    (this.soldier_hp_mask.width = 77),
                    (this.soldier_hp_mask.children[0].active = this.team_info % 2 == i.GlobalParams.MatchMyIndex % 2),
                    (this.soldier_hp_mask.children[1].active = this.team_info % 2 != i.GlobalParams.MatchMyIndex % 2),
                    e.id == r.SoldierType.near_soldier
                        ? (this.soldier_kill_id = r.KillType.near_soldier)
                        : e.id == r.SoldierType.far_soldier
                        ? (this.soldier_kill_id = r.KillType.far_soldier)
                        : e.id == r.SoldierType.super_soldier && (this.soldier_kill_id = r.KillType.super_soldier),
                    (this.be_hit_ske.node.active = !1);
            }),
            (t.prototype.soldierBeHit = function (e, t) {
                var o = this;
                (this.have_hp -= e),
                    this.emitEvent(a.default.SEND_SHOW_BE_HIT_INFO, {
                        attack: e,
                        my_team: this.team_info == r.TeamInfo.left_team ? 0 : 1,
                        end_pos: cc.v2(this.node.getPosition().x, this.node.getPosition().y + 80)
                    }),
                    (this.soldier_hp_mask.width = (77 * this.have_hp) / this.node_info.ma_hp),
                    (this.be_hit_ske.node.active = !0),
                    this.be_hit_ske.setAnimation(0, "受击特效", !1),
                    this.have_hp <= 0 &&
                        !this.is_die &&
                        ((this.is_die = !0),
                        this.scheduleOnce(function () {
                            o.emitEvent(a.default.SEND_ROLE_BE_KILL_INFO, {
                                kill: t,
                                be_kill: o.soldier_kill_id,
                                team: o.team_info
                            }),
                                o.soldier_kill_id == r.KillType.super_soldier
                                    ? s.default.getInstance().Recovey(o.node, r.Pool_Type.super_soldier)
                                    : s.default.getInstance().Recovey(o.node, r.Pool_Type.soldier);
                        }, 0.01));
            }),
            __decorate([d(sp.Skeleton)], t.prototype, "soldier_ske", void 0),
            __decorate([d(cc.Node)], t.prototype, "soldier_hp_mask", void 0),
            __decorate([d(sp.SkeletonData)], t.prototype, "soldier_skeleton", void 0),
            __decorate([d(sp.Skeleton)], t.prototype, "be_hit_ske", void 0),
            __decorate([c], t)
        );
    })(n.default);
o.default = h;
